/**
 * 版权所有 2009-2015 中国中医科学院中医药信息研究所 何前锋 frontpeak@yahoo.com.cn
 **/
package cn.ac.cintcm.sh.domain;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class AbsentElement {
    public static final String YAO = "找不到的药";
    public static final String WEI = "找不到的味";
    public static final String QI = "找不到的气";
    
    private HashMap<String, Set<String>> elements;
    
    public AbsentElement() {
        elements = new HashMap<String, Set<String>>();
    }
    
    public Set<String> getAbsentElements(String name) {
        return elements.get(name);
    }

    public String getAbsentString(String name) {
        Set<String> set = elements.get(name);
        StringBuilder sb = new StringBuilder();
        if (set != null) {
            for (String s : set) {
                sb.append(s);
                sb.append(" ");
            }
        }
        return sb.toString();
    }
    
    public String getAbsentString() {
        Set<String> set = elements.keySet();
        StringBuilder sb = new StringBuilder();
        if (set != null) {
            for (String s : set) {
                sb.append(s);
                sb.append(":");
                sb.append(getAbsentString(s));
                sb.append("\r\n");
            }
        }
        return sb.toString();
    }   
    
    public void addAbsentElement(String name, String element) {
        Set<String> set = elements.get(name);
        if (set == null) {
            set = new HashSet<String>();
        }
        set.add(element);
        elements.put(name, set);
    }

    public HashMap<String, Set<String>> getElements() {
        return elements;
    }
}